package org.jetpac.chatscript.client;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

public class MenuPanel extends Composite {

	private final VerticalPanel menuPanel = new VerticalPanel();
	private static int testNumber=0;
	
	public MenuPanel(final MainPanel mainPanel) {
		
		Button scrollToTop= new Button("Scroll to Top");
		Button fillTestChatData = new Button("TestFill");
		Button scrollToBottom = new Button ("Scroll to Bottom");
		Button clearButton = new Button("Clear");

//		menuPanel.setVerticalAlignment(VerticalPanel.ALIGN_TOP);
		menuPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
		
		menuPanel.add(scrollToTop);
		menuPanel.add(fillTestChatData);
		menuPanel.add(clearButton);
		menuPanel.add(scrollToBottom);
		
		
		scrollToTop.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				mainPanel.chatPanel.scrollToTop();
			}
		});
		
		scrollToBottom.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				mainPanel.chatPanel.scrollToBottom();
			}
		});
		
		fillTestChatData.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				mainPanel.nickNameTextBox.setText("Test bot");
				for (int i=testNumber; i<=testNumber+500; i++) {
					mainPanel.addChatString("Comment number" + String.valueOf(i) + ".");
				}
				testNumber=testNumber+500;
				mainPanel.nickNameTextBox.setText("");
			}
		});
		
		clearButton.addClickHandler(new ClickHandler() {
			
			public void onClick(ClickEvent event) {
				mainPanel.chatPanel.clear();
			}
		});
		
		initWidget(menuPanel);
		menuPanel.setStylePrimaryName("menuPanel");
	}

}
